//package com.billow.book.api;
//
//import com.billow.book.model.User;
//import com.billow.book.model.vo.ResultVo;
//import com.billow.book.utils.ResultUtils;
//import org.apache.shiro.SecurityUtils;
//import org.apache.shiro.authc.UsernamePasswordToken;
//import org.apache.shiro.subject.Subject;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//@RestController
//@RequestMapping("/user")
//public class UserApi {
//
//    @PostMapping("/login")
//    public ResultVo login(@RequestBody User user) {
//        ResultVo resultVo = ResultUtils.buildSuccess();
//        Subject subject = SecurityUtils.getSubject();
//        UsernamePasswordToken token = new UsernamePasswordToken(user.getUsername(), user.getPassword());
//        try {
//            subject.login(token);
//            resultVo.setMsg("登录成功");
//            return resultVo;
//        } catch (Exception e) {
//            resultVo.setMsg("用户名或密码错误");
//            return resultVo;
//        }
//    }
//}